package com.example.demo.common;

import lombok.Data;

/**
 * 结果封装
 *
 * @author Administrator
 */
@Data
public class BaseResult<T> {

    public int code = 0;
    public String msg = "操作成功";
    public T data = null;
    public String eventId = null;

    public static <T> BaseResult<T> getInstance(int code, String msg, T data) {
        BaseResult<T> result = new BaseResult<>();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public static <T> BaseResult<T> getInstance(int code, String msg) {
        BaseResult<T> result = new BaseResult<>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static <T> BaseResult<T> getInstance(String msg) {
        BaseResult<T> result = new BaseResult<>();
        result.setCode(0);
        result.setMsg(msg);
        return result;
    }

    public static <T> BaseResult<T> getInstance(T data) {
        BaseResult<T> result = new BaseResult<>();
        result.setCode(0);
        result.setMsg("操作成功");
        result.setData(data);
        return result;
    }

    public static <T> BaseResult<T> getInstance() {
        BaseResult<T> result = new BaseResult<>();
        result.setCode(0);
        result.setMsg("操作成功");
        return result;
    }

    public void setEventId(final String eventId) {
        this.eventId = eventId;
    }

}
